<!-- 三级教育管理 -->
<template>
	<view>
		<bg-search placeholder="请输入姓名" @search="onSearch"></bg-search>
		<view class="mt-3 bg-white" v-if="dataList.length>0">
			<bg-cell2 v-for="i,idx in dataList" :key="idx" :showArrow="true" @tap="gotoDetail(i)">
				<template slot="label">
					<view class="info-area">
						<view class="margin-right-xl">{{i.userName}}({{getLastFour(i.idCardNo)}})</view>
						<view>已上传 <text class="font-red">{{i.uploadCount}}</text> 张 </view>
					</view>
				</template>
			</bg-cell2>
		</view>
		<u-empty v-else></u-empty>
	</view>
</template>

<script>
	import {threeEdu} from "@/api/system/study.js"
	export default {
		data() {
			return {
				projectId:'',
				userName:'',
				dataList:[]
			}
		},
		onLoad(options){
			this.projectId = options.projectId
		},
		mounted() {
			this.getData()
			uni.$on("refresh-three", ()=>{
				this.getData()
			})
		},
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url:'/pages/enter/education/upload'
			})
		},
		methods: {
			getData(){
				threeEdu({projectId:this.projectId, userName:this.userName}).then(res=>{
					this.dataList = res.data
				})
			},
			onSearch(keyword){
				this.userName = keyword;
				this.getData()
			},
			gotoDetail(i){
				uni.navigateTo({
					url:"/pages/enter/education/upload-detail?id="+i.id
				})
			},
			getLastFour(str){
				if(str){
					return str.substring(str.length - 4);
				} else {
					return ''
				}
			}
		}
	}
</script>

<style scoped>
.info-area {
	font-size: 24rpx;
	font-family: PingFang SC, PingFang SC-Medium;
	font-weight: 500;
	text-align: left;
	color: #343434;
	display: flex;
	justify-content: space-between;
}
</style>
